/// @file circularbuffer.h
/// @brief Declaration of the CircularBuffer class
/// @date 23/09/2009
/// @author J.Stadelmann, Reds, Heig-vd

#ifndef CIRCULARBUFFER_H
#define CIRCULARBUFFER_H


#include <QMutex>

/// The capacity of the circula buffer
#define BUFFER_CAPACITY     256

/// A fixed size circular buffer
class CircularBuffer
{
public:

    /// Constructor
    CircularBuffer();

    /// Destructor
    virtual ~CircularBuffer();

    /// Appends a value to the buffer
    void    append(short s);

    /// Transforms the circular buffer to an array
    int     toArray(short* array, int size, bool newOnly = false);

private:
    short               m_buffer[BUFFER_CAPACITY];
    int                 m_iWritePos;
    int                 m_iReadPos;
    QMutex     m_hMutex;
};

#endif // CIRCULARBUFFER_H
